package com.dynamicprogram;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution1027 {
    public int longestArithSeqLength(int[] nums) {
        int[][] dp = new int[nums.length][1001];
        int res = 0;
        for (int i = 1; i < nums.length; i++) {
            for (int j = 0; j < i; j++) {
                int k = nums[i] - nums[j] + 500;
                dp[i][k] = dp[j][k] + 1;
                res = Math.max(res, dp[i][k]);
            }
        }
        return res + 1;
    }
}
